package BaseClass;

public class Book {

    private String bookID;
    private String bookName;
    private String writer;
    private String publisher;
    private String intro;
    private String price;
    private int remaining;
    private String picture;

    public Book() {
    }

    public Book(String bookID, String bookName) {
        this.bookID = bookID;
        this.bookName = bookName;
    }

    public Book(String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture) {
        this.bookID = bookID;
        this.bookName = bookName;
        this.writer = writer;
        this.publisher = publisher;
        this.intro = intro;
        this.price = price;
        this.remaining = remaining;
        this.picture = picture;
    }

    public void setBook(String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture) {
        this.bookID = bookID;
        this.bookName = bookName;
        this.writer = writer;
        this.publisher = publisher;
        this.intro = intro;
        this.price = price;
        this.remaining = remaining;
        this.picture = picture;
    }

    /**
     *String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture.
     * @return String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture.
     */
    public Object[] getBookAttributeList(){
        Object[] list = new Object[8];
        list[0] = this.bookID;
        list[1] = this.bookName;
        list[2] = this.writer;
        list[3] = this.publisher;
        list[4] = this.intro;
        list[5] = this.price;
        list[6] = this.remaining;
        list[7] = this.picture;
        return list;
    }

    /**
     * String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture
     * @param list String bookID, String bookName, String writer, String publisher, String intro, String price, int remaining, String picture
     * @return true or false.
     */
    public boolean setBookAttributeList(Object[] list){
        if (list.length == 8) {
            this.setBookID((String) list[0]);
            this.setBookName((String) list[1]);
            this.setWriter((String) list[2]);
            this.setPublisher((String)list[3]);
            this.setIntro((String)list[4]);
            this.setPrice((String)list[5]);
            this.setRemaining((int)list[6]);
            this.setPicture((String)list[7]);
            return true;
        } else {
            return false;
        }
    }

    public Book getNewBook(){
        Book book = new Book();
        book.setBookID(this.getBookID());
        book.setBookName(this.getBookName());
        book.setWriter(this.getWriter());
        book.setPublisher(this.getPublisher());
        book.setIntro(this.getIntro());
        book.setPrice(this.getPrice());
        book.setRemaining(this.getRemaining());
        book.setPicture(this.getPicture());
        return book;
    }


    public String getBookID() {
        return bookID;
    }

    public void setBookID(String bookID) {
        this.bookID = bookID;
    }

    public String getBookName() {
        return bookName;
    }

    public void setBookName(String bookName) {
        this.bookName = bookName;
    }

    public String getWriter() {
        return writer;
    }

    public void setWriter(String writer) {
        this.writer = writer;
    }

    public String getPublisher() {
        return publisher;
    }

    public void setPublisher(String publisher) {
        this.publisher = publisher;
    }

    public String getIntro() {
        return intro;
    }

    public void setIntro(String intro) {
        this.intro = intro;
    }

    public String getPrice() {
        return price;
    }

    public void setPrice(String price) {
        this.price = price;
    }

    public int getRemaining() {
        return remaining;
    }

    public void setRemaining(int remaining) {
        this.remaining = remaining;
    }

    public String getPicture() {
        return picture;
    }

    public void setPicture(String picture) {
        this.picture = picture;
    }

    @Override
    public String toString() {
        return "Book{" +
                "bookID='" + bookID + '\'' +
                ", bookName='" + bookName + '\'' +
                ", writer='" + writer + '\'' +
                ", publisher='" + publisher + '\'' +
                ", intro='" + intro + '\'' +
                ", price='" + price + '\'' +
                ", remaining=" + remaining +
                ", picture='" + picture + '\'' +
                '}';
    }
}
